// Licensed to Elasticsearch B.V under one or more agreements.
// Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
//
// ███╗   ██╗ ██████╗ ████████╗██╗ ██████╗███████╗
// ████╗  ██║██╔═══██╗╚══██╔══╝██║██╔════╝██╔════╝
// ██╔██╗ ██║██║   ██║   ██║   ██║██║     █████╗
// ██║╚██╗██║██║   ██║   ██║   ██║██║     ██╔══╝
// ██║ ╚████║╚██████╔╝   ██║   ██║╚██████╗███████╗
// ╚═╝  ╚═══╝ ╚═════╝    ╚═╝   ╚═╝ ╚═════╝╚══════╝
// ------------------------------------------------
//
// This file is automatically generated.
// Please do not edit these files manually.
//
// ------------------------------------------------

#nullable restore

using Elastic.Clients.Elasticsearch.Fluent;
using Elastic.Clients.Elasticsearch.Serialization;
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Text.Json;
using System.Text.Json.Serialization;

namespace Elastic.Clients.Elasticsearch.Analysis;

public sealed partial class IcuCollationTokenFilter : ITokenFilter
{
	[JsonInclude, JsonPropertyName("alternate")]
	public Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? Alternate { get; set; }
	[JsonInclude, JsonPropertyName("case_first")]
	public Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? CaseFirst { get; set; }
	[JsonInclude, JsonPropertyName("case_level")]
	public bool? CaseLevel { get; set; }
	[JsonInclude, JsonPropertyName("country")]
	public string? Country { get; set; }
	[JsonInclude, JsonPropertyName("decomposition")]
	public Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? Decomposition { get; set; }
	[JsonInclude, JsonPropertyName("hiragana_quaternary_mode")]
	public bool? HiraganaQuaternaryMode { get; set; }
	[JsonInclude, JsonPropertyName("language")]
	public string? Language { get; set; }
	[JsonInclude, JsonPropertyName("numeric")]
	public bool? Numeric { get; set; }
	[JsonInclude, JsonPropertyName("rules")]
	public string? Rules { get; set; }
	[JsonInclude, JsonPropertyName("strength")]
	public Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? Strength { get; set; }

	[JsonInclude, JsonPropertyName("type")]
	public string Type => "icu_collation";

	[JsonInclude, JsonPropertyName("variable_top")]
	public string? VariableTop { get; set; }
	[JsonInclude, JsonPropertyName("variant")]
	public string? Variant { get; set; }
	[JsonInclude, JsonPropertyName("version")]
	public string? Version { get; set; }
}

public sealed partial class IcuCollationTokenFilterDescriptor : SerializableDescriptor<IcuCollationTokenFilterDescriptor>, IBuildableDescriptor<IcuCollationTokenFilter>
{
	internal IcuCollationTokenFilterDescriptor(Action<IcuCollationTokenFilterDescriptor> configure) => configure.Invoke(this);

	public IcuCollationTokenFilterDescriptor() : base()
	{
	}

	private Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? AlternateValue { get; set; }
	private Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? CaseFirstValue { get; set; }
	private bool? CaseLevelValue { get; set; }
	private string? CountryValue { get; set; }
	private Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? DecompositionValue { get; set; }
	private bool? HiraganaQuaternaryModeValue { get; set; }
	private string? LanguageValue { get; set; }
	private bool? NumericValue { get; set; }
	private string? RulesValue { get; set; }
	private Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? StrengthValue { get; set; }
	private string? VariableTopValue { get; set; }
	private string? VariantValue { get; set; }
	private string? VersionValue { get; set; }

	public IcuCollationTokenFilterDescriptor Alternate(Elastic.Clients.Elasticsearch.Analysis.IcuCollationAlternate? alternate)
	{
		AlternateValue = alternate;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor CaseFirst(Elastic.Clients.Elasticsearch.Analysis.IcuCollationCaseFirst? caseFirst)
	{
		CaseFirstValue = caseFirst;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor CaseLevel(bool? caseLevel = true)
	{
		CaseLevelValue = caseLevel;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Country(string? country)
	{
		CountryValue = country;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Decomposition(Elastic.Clients.Elasticsearch.Analysis.IcuCollationDecomposition? decomposition)
	{
		DecompositionValue = decomposition;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor HiraganaQuaternaryMode(bool? hiraganaQuaternaryMode = true)
	{
		HiraganaQuaternaryModeValue = hiraganaQuaternaryMode;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Language(string? language)
	{
		LanguageValue = language;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Numeric(bool? numeric = true)
	{
		NumericValue = numeric;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Rules(string? rules)
	{
		RulesValue = rules;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Strength(Elastic.Clients.Elasticsearch.Analysis.IcuCollationStrength? strength)
	{
		StrengthValue = strength;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor VariableTop(string? variableTop)
	{
		VariableTopValue = variableTop;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Variant(string? variant)
	{
		VariantValue = variant;
		return Self;
	}

	public IcuCollationTokenFilterDescriptor Version(string? version)
	{
		VersionValue = version;
		return Self;
	}

	protected override void Serialize(Utf8JsonWriter writer, JsonSerializerOptions options, IElasticsearchClientSettings settings)
	{
		writer.WriteStartObject();
		if (AlternateValue is not null)
		{
			writer.WritePropertyName("alternate");
			JsonSerializer.Serialize(writer, AlternateValue, options);
		}

		if (CaseFirstValue is not null)
		{
			writer.WritePropertyName("case_first");
			JsonSerializer.Serialize(writer, CaseFirstValue, options);
		}

		if (CaseLevelValue.HasValue)
		{
			writer.WritePropertyName("case_level");
			writer.WriteBooleanValue(CaseLevelValue.Value);
		}

		if (!string.IsNullOrEmpty(CountryValue))
		{
			writer.WritePropertyName("country");
			writer.WriteStringValue(CountryValue);
		}

		if (DecompositionValue is not null)
		{
			writer.WritePropertyName("decomposition");
			JsonSerializer.Serialize(writer, DecompositionValue, options);
		}

		if (HiraganaQuaternaryModeValue.HasValue)
		{
			writer.WritePropertyName("hiragana_quaternary_mode");
			writer.WriteBooleanValue(HiraganaQuaternaryModeValue.Value);
		}

		if (!string.IsNullOrEmpty(LanguageValue))
		{
			writer.WritePropertyName("language");
			writer.WriteStringValue(LanguageValue);
		}

		if (NumericValue.HasValue)
		{
			writer.WritePropertyName("numeric");
			writer.WriteBooleanValue(NumericValue.Value);
		}

		if (!string.IsNullOrEmpty(RulesValue))
		{
			writer.WritePropertyName("rules");
			writer.WriteStringValue(RulesValue);
		}

		if (StrengthValue is not null)
		{
			writer.WritePropertyName("strength");
			JsonSerializer.Serialize(writer, StrengthValue, options);
		}

		writer.WritePropertyName("type");
		writer.WriteStringValue("icu_collation");
		if (!string.IsNullOrEmpty(VariableTopValue))
		{
			writer.WritePropertyName("variable_top");
			writer.WriteStringValue(VariableTopValue);
		}

		if (!string.IsNullOrEmpty(VariantValue))
		{
			writer.WritePropertyName("variant");
			writer.WriteStringValue(VariantValue);
		}

		if (!string.IsNullOrEmpty(VersionValue))
		{
			writer.WritePropertyName("version");
			writer.WriteStringValue(VersionValue);
		}

		writer.WriteEndObject();
	}

	IcuCollationTokenFilter IBuildableDescriptor<IcuCollationTokenFilter>.Build() => new()
	{
		Alternate = AlternateValue,
		CaseFirst = CaseFirstValue,
		CaseLevel = CaseLevelValue,
		Country = CountryValue,
		Decomposition = DecompositionValue,
		HiraganaQuaternaryMode = HiraganaQuaternaryModeValue,
		Language = LanguageValue,
		Numeric = NumericValue,
		Rules = RulesValue,
		Strength = StrengthValue,
		VariableTop = VariableTopValue,
		Variant = VariantValue,
		Version = VersionValue
	};
}